#include "../../source/server.hpp"

void OnConnected(const PtrConnection &conn){
    LOG_DEBUG("NEW CONNECTION: %p", conn.get());
}
void OnClosed(const PtrConnection &conn){
    LOG_DEBUG("CLOSED CONNECTION: %p", conn.get());
}
void OnMessage(const PtrConnection &conn, Buffer *buf){
    LOG_DEBUG("RECV MSG: %s", buf->ReadPos());
    buf->MoveReadOffset(buf->ReadAbleSize());
    std::string msg = "Hello IsLand";
    conn->Send(msg.c_str(), msg.size());
}


int main(){
    TcpServer server(8080);
    server.SetThreadCount(2);
    // server.EnableInactiveRelease(10);

    server.SetClosedCallback(OnClosed);
    server.SetConnectedCallback(OnConnected);
    server.SetMessageCallback(OnMessage);

    server.Start();

    return 0;
}